<html>
    <head>
        <!-- PyScript CSS -->
        <link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css">
        <!-- This script tag bootstraps PyScript -->
        <script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
    </head>
<body>  
    <py-config>
        packages = ["requests"]
    </py-config>

    <div>
        <input id="content" type="text" />
        <button id="new-task-btn" type="submit" py-click="query">
            Search
        </button>
    </div>

    <py-script>
        import requests
        from pyscript import display
        from pyweb import pydom
    
        content = pydom["#content"][0]
        
        def query(e):
            url = 'http://121.41.112.199:8080/genshin/get'
            url += "?word=" + content.value

            
            data = requests.get(url)
            response_dict = data.json()

            for item in response_dict["data"]["records"]:
                if item.get("zhCN"): display("\n中文:" + item.get("zhCN"))
                if item.get("en"): display("\n英文:" + item.get("en"))
                if item.get("ja"): display("\n日语:" + item.get("ja"))
                # 打印标签
                if item.get("tags"):
                    # 标签不为空
                    display("标签：" + item.get("tags").replace(","," "))
                display("\n\n")
    </py-script>
</body>
</html>